package com.jyxd.web.controller.czform;

import com.jyxd.web.data.dto.HttpResult;
import com.jyxd.web.hiscz.service.SSOService;
import com.jyxd.web.util.ComputerConfiguration;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Api(tags = "长治单点登录对接接口")
@Controller
@RequestMapping(value = "/hisWeb")
public class HisWebController {

    @Autowired
    private SSOService ssoService;

    @Autowired
    private ComputerConfiguration computerConfiguration;

    @ApiOperation("单点登录注册接口")
    @RequestMapping(value = "/loginRegister", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult loginInfoRegister(@RequestBody Map<String, Object> map) {
        return ssoService.loginInfoRegister(map);
    }

    @ApiOperation("获取客户端电脑ip")
    @RequestMapping(value = "/getIp", method = RequestMethod.POST)
    @ResponseBody
    public String getIp(HttpServletRequest request) {
        return computerConfiguration.getIp(request);
    }

    @ApiOperation("获取客户端电脑Mac")
    @RequestMapping(value = "/getMac", method = RequestMethod.POST)
    @ResponseBody
    public String getMac(HttpServletRequest request) throws Exception {
        return computerConfiguration.getMac(request);
    }


    @ApiOperation("单点登录安全验证")
    @RequestMapping(value = "/loginVerify", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult loginVerify(@RequestBody Map<String, Object> map,HttpServletRequest request) {
        return ssoService.loginVerify(map,request);
    }

    @ApiOperation("单点登录系统退出通知")
    @RequestMapping(value = "/loginExit", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult loginExit(@RequestBody Map<String, Object> map,HttpServletRequest request) {
        return ssoService.loginExit(map,request);
    }

}
